﻿using Microsoft.EntityFrameworkCore;
using OpenAuth.Repository.Domain;

namespace OpenAuth.Repository
{
    public partial class OpenAuthDBContext : DbContext
    {
        #region 使用ef CodeFirstFromDb模式 需要把model和数据库之间做映射
        //使用ef创建链接之后要把代码model和数据库中做映射
        //1.在model上设置特性
        //2.新建mapping文件
        #endregion


        #region 配置 EF 框架服务
        //1.将把数据库连接字符串保存在一个 JSON 的配置文件中
        //2.同样的，还需要在 Startup 类的 ConfigureServices 方法中添加 EF 服务
        //3.EF 框架和 ASP.NET 和 MVC框架一样，都使用依赖注入。为了能够注入，运行时需要知道 EF 框架使用的各种服务
        //4.当然了，有一个简单的配置 API 可以用来添加我们需要的所有默认服务
        #endregion


        /// <summary>
        ///  //构造函数中接受一个 DbContextOptions<TContext>对象并将其传递给 DbContext 的基础构造函数
        /// </summary>
        /// <param name="options"></param>
        public OpenAuthDBContext(DbContextOptions<OpenAuthDBContext> options)
            : base(options)
        {
            
        }
        public virtual DbSet<CheckOutOrderMZEntity> CheckOutOrderMZ { get; set; }
        //充值记录表
        public virtual DbSet<PayOrderZY> PayOrderZY { get; set; }
        public virtual DbSet<PayOrder> PayOrders { get; set; }
        public virtual DbSet<ApiLog> ApiLogs { get; set; }
        public virtual DbSet<Application> Applications { get; set; }
        public virtual DbSet<Category> Categories { get; set; }
        public virtual DbSet<CategoryType> CategoryTypes { get; set; }
        public virtual DbSet<FlowInstance> FlowInstances { get; set; }
        public virtual DbSet<FlowInstanceOperationHistory> FlowInstanceOperationHistorys { get; set; }
        public virtual DbSet<FlowInstanceTransitionHistory> FlowInstanceTransitionHistorys { get; set; }
        public virtual DbSet<FlowScheme> FlowSchemes { get; set; }
        public virtual DbSet<Form> Forms { get; set; }
        public virtual DbSet<Module> Modules { get; set; }
        public virtual DbSet<ModuleElement> ModuleElements { get; set; }
        public virtual DbSet<Org> Orgs { get; set; }
        public virtual DbSet<Relevance> Relevances { get; set; }
        public virtual DbSet<Resource> Resources { get; set; }
        public virtual DbSet<Role> Roles { get; set; }
        public virtual DbSet<User> Users { get; set; }
        public virtual DbSet<UploadFile> UploadFiles { get; set; }
        public virtual DbSet<TriageSign> TriageSigns { get; set; }
        public virtual DbSet<FrmLeaveReq> FrmLeaveReqs { get; set; }
        public virtual DbSet<RefundOrderEntity> RefundOrderEntity { get; set; }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<TriageSign>()
               .Property(p => p.XH).HasColumnType("decimal(12,0)");
            modelBuilder.Entity<TriageSign>()
               .Property(p => p.GHXH).HasColumnType("decimal(12,0)");
            modelBuilder.Entity<TriageSign>()
               .Property(p => p.PATID).HasColumnType("decimal(12,0)");
            modelBuilder.Entity<TriageSign>()
               .Property(p => p.YYXH).HasColumnType("decimal(12,0)");


        }
    }
}
